package 
{
	//import flash
	import flash.display.Sprite;
	import flash.events.Event;
	
	//import local
	import logic.*;
	import structures.*;
	
	public class Main extends Sprite 
	{
		private var gamefield:GameField;
		private var eventdispatch:EventDispatch;
		private var unitfactory:UnitFactory;
		private var statemachine:StateMachine;
		
		public function Main():void 
		{
			addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event):void
		{
			//logic units
			statemachine = new StateMachine();
			gamefield = new GameField(statemachine);
			unitfactory = new UnitFactory();
			eventdispatch = new EventDispatch(statemachine);	
			
			
			//add to stage - unsure if all necessary
			{
			stage.addChild(eventdispatch);
			stage.addChild(gamefield);
			stage.addChild(unitfactory);
			stage.addChild(statemachine);
			}
			
			//add classes to unitfactory
			{
			unitfactory.push(Struct1);
			unitfactory.push(Struct2);
			}
			
			
		}
		
	}
	
}